From: Félix Piédallu Date: Wed, 24 Jul 2019 10:58:54 +0000 (+0200) Subject: Fix git-version.h handling X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~11^2~67 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=cff554329e5930f93cab919926833021adc58ad1;p=babl.git Fix git-version.h handling --- diff --git a/babl/git-version.h.in b/babl/git-version.h.in index d517ef7..a9f87e2 100644 --- a/babl/git-version.h.in +++ b/babl/git-version.h.in @@ -1,5 +1,6 @@ #ifndef __GIT_VERSION_H__ #define __GIT_VERSION_H__ + #define BABL_GIT_VERSION "@BABL_GIT_VERSION@" -#define BABL_GIT_LAST_COMMIT_YEAR "@BABL_GIT_LAST_COMMIT_YEAR@" + #endif /* __GIT_VERSION_H__ */ diff --git a/babl/meson.build b/babl/meson.build index 0510ebd..b2a2d4e 100644 --- a/babl/meson.build +++ b/babl/meson.build @@ -42,40 +42,30 @@ babl_version_h = configure_file( # already exists because then we are probably working with a tarball # in which case the git-version.h we ship is correct. -if test_bin.found() and git_bin.found() - if run_command( - [test_bin.path(), '-d', join_paths(meson.source_root(), '.git')] - ).returncode() == 0 - # git repo and git is available - git_version = run_command([git_bin.path(), 'describe', '--always'] - ).stdout().strip() - git_last_commit_year = run_command([git_bin.path(), - 'log', '-n1', '--date=format:%Y', '--pretty=%cd'] - ).stdout().strip() - endif -else - # Not a git repo so expect git-version.h to exist - if test_bin.found() and git_bin.found() and - run_command( - [test_bin.path(), '-f', 'git-version.h'] - ).returncode() == 0 - git_version_h = 'git-version.h' - else - git_version = 'Unknown, shouldn\'t happen' - git_last_commit_year = 0 - endif -endif -if not is_variable('git_version_h') - git_conf = configuration_data() - git_conf.set('BABL_GIT_VERSION', git_version) - git_conf.set('BABL_GIT_LAST_COMMIT_YEAR', git_last_commit_year) - git_version_h = configure_file( - input: 'git-version.h.in', +is_git_repo = ( + test_bin.found() and + git_bin.found() and + run_command(test_bin, '-d', meson.source_root() / '.git').returncode() == 0 +) + +if is_git_repo + git_version_h = vcs_tag( + input : 'git-version.h.in', output: 'git-version.h', - configuration: git_conf, + replace_string: '@BABL_GIT_VERSION@', + command: [ git_bin.path(), 'describe', '--always' ], ) -endif + meson.add_dist_script( + [ 'sh', '-c', ' '.join( + [ 'cp', git_version_h.full_path(), '${MESON_DIST_ROOT}/babl' ] + )] + ) + +else + git_version_h = files('git-version.h') + +endif babl_sources = [ 'babl-cache.c', diff --git a/meson.build b/meson.build index 983b723..adc5d82 100644 --- a/meson.build +++ b/meson.build @@ -183,7 +183,7 @@ if cc.has_argument('-mmmx') and get_option('enable-mmx') 'Define to 1 if MMX assembly is available.') # sse assembly - if cc.has_argument('-msse') and get_option('enable-sse') + if cc.has_argument('-msse') and get_option('enable-sse') if cc.compiles('asm ("movntps %xmm0, 0");') add_project_arguments('-msse', language: 'c') message('sse assembly available') @@ -251,7 +251,7 @@ if not platform_win32 endif foreach header: check_headers if cc.has_header(header[1]) - conf.set(header[0], 1, description: + conf.set(header[0], 1, description: 'Define to 1 if the <@0@> header is available'.format(header[1])) endif endforeach @@ -261,12 +261,12 @@ endforeach # general check_functions = [ ['HAVE_GETTIMEOFDAY', 'gettimeofday', ''], - ['HAVE_RINT', 'rint' , ''], + ['HAVE_RINT', 'rint' , ''], ['HAVE_SRANDOM', 'srandom' , ''], ] foreach func: check_functions if cc.has_function(func[1], prefix: '#include ' + func[2]) - conf.set(func[0], 1, description: + conf.set(func[0], 1, description: 'Define to 1 if the @0@() function is available'.format(func[1])) endif endforeach @@ -288,7 +288,7 @@ endif if get_option('with-lcms') lcms = dependency('lcms2', required: true, native: false) if lcms.found() - conf.set('HAVE_LCMS', 1, description: + conf.set('HAVE_LCMS', 1, description: 'Define to 1 if liblcms2 is available') endif else @@ -302,7 +302,7 @@ if platform_android else log = [] endif -if platform_win32 +if platform_win32 dl = [] else dl = cc.find_library('dl', required: false)